<?php

namespace app\admin\model;

use think\Model;
use fast\Tree;

class Classroomeplan extends Model
{
    // 表名
    public $name = 'course_classroomeplan';
    public $prefix_new = 'fa_';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    public $data;



    public function getClasses_idTextAttr($value, $data = array())
    {
        $s = array();
        $content = [];
        if ($value) {
            $nn = preg_split("/,/", $value);
        } else {
            $nn = array();
        }
        for ($i = 0; $i < count($nn); $i++) {
            if ($nn[$i] == "") continue;
            if (isset($content[$nn[$i]])) $s[] = $content[$nn[$i]];
        }
        return join(",", $s);
    }

    public function getOcation_idTextAttr($value, $data = array())
    {
        $s = array();
        $content = [];
        if ($value) {
            $nn = preg_split("/,/", $value);
        } else {
            $nn = array();
        }
        for ($i = 0; $i < count($nn); $i++) {
            if ($nn[$i] == "") continue;
            if (isset($content[$nn[$i]])) $s[] = $content[$nn[$i]];
        }
        return join(",", $s);
    }

    /**
     * 检查两个时间段是否冲突
     * @param string $time1Start 时间段1开始时间
     * @param string $time1End 时间段1结束时间  
     * @param string $time2Start 时间段2开始时间
     * @param string $time2End 时间段2结束时间
     * @return bool 是否冲突
     */
    public static function isTimeConflict($time1Start, $time1End, $time2Start, $time2End)
    {
        $start1 = strtotime($time1Start);
        $end1 = strtotime($time1End);
        $start2 = strtotime($time2Start);
        $end2 = strtotime($time2End);

        // 检查时间段是否重叠
        return !($end1 <= $start2 || $start1 >= $end2);
    }
}
